using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using sbMembership.Library.Presenters;
namespace Tests.sbMembership.EditRole
{
    [TestFixture]
    public class EditRoleTest
    {
        private MockEditRoleView mockView;
        private EditRolePresenter presenter;
        private bool editRoleCompleteEventRaised;

        [TestFixtureSetUp]
        public void Setup()
        {
            mockView = new MockEditRoleView();
            presenter = new EditRolePresenter(mockView);
            mockView.AttachPresenter(presenter);
        }

        [Test]
        public void InitView()
        {
            presenter.InitViewFor(TestSetup.testEditRoleName);
            Assert.AreEqual(mockView.RoleToEdit, TestSetup.testEditRoleName);
        }

        [Test]
        public void EditRole()
        {
            presenter.InitViewFor(TestSetup.testRoleName);
            presenter.EditRoleCompleteEvent = new EventHandler(OnEditRoleCompleteEvent);
            presenter.AssignUser(TestSetup.testEditUserName);
            Assert.IsTrue(editRoleCompleteEventRaised);
        }

        void OnEditRoleCompleteEvent(object sender, EventArgs e)
        {
            editRoleCompleteEventRaised = true;
        }

    }
}
